home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / Libraries / DCLAP 6d / dclap6d / corelib / ncbistr.h < prev    next >
Text File  |  1996-07-05  |  8KB  |  207 lines

  1. /*   ncbistr.h
  2. * ===========================================================================
  3. *
  4. *                            PUBLIC DOMAIN NOTICE                          
  5. *               National Center for Biotechnology Information
  6. *                                                                          
  7. *  This software/database is a "United States Government Work" under the
  8. *  terms of the United States Copyright Act.  It was written as part of
  9. *  the author's official duties as a United States Government employee and 
  10. *  thus cannot be copyrighted.  This software/database is freely available 
  11. *  to the public for use. The National Library of Medicine and the U.S.
  12. *  Government have not placed any restriction on its use or reproduction.
  13. *
  14. *  Although all reasonable efforts have been taken to ensure the accuracy
  15. *  and reliability of the software and data, the NLM and the U.S.
  16. *  Government do not and cannot warrant the performance or results that
  17. *  may be obtained by using this software or data. The NLM and the U.S.
  18. *  Government disclaim all warranties, express or implied, including
  19. *  warranties of performance, merchantability or fitness for any particular
  20. *  purpose.
  21. *
  22. *  Please cite the author in any work or product based on this material.
  23. *
  24. * ===========================================================================
  25. *
  26. * File Name:  ncbistr.h
  27. *
  28. * Author:  Gish, Kans, Ostell, Schuler
  29. *
  30. * Version Creation Date:   1/1/91
  31. *
  32. * $Revision: 2.3 $
  33. *
  34. * File Description: 
  35. *       prototypes for portable string routines
  36. *
  37. * Modifications:
  38. * --------------------------------------------------------------------------
  39. * Date     Name        Description of modification
  40. * -------  ----------  -----------------------------------------------------
  41. * 09-19-91 Schuler     Added macros to alias actual ANSI string functions
  42. * 04-15-93 Schuler     Changed _cdecl to LIBCALL
  43. * 05-27-93 Schuler     Added const qualifiers to match ANSI cognates
  44. *
  45. * ==========================================================================
  46. */
  47.  
  48. #ifndef _NCBISTR_
  49. #define _NCBISTR_
  50.  
  51. #ifdef __cplusplus
  52. extern "C" {
  53. #endif
  54.  
  55. int LIBCALL Nlm_StrICmp PROTO((const char FAR *a, const char FAR *b));
  56. int LIBCALL Nlm_StrNICmp PROTO((const char FAR *a, const char FAR *b, Nlm_sizeT max));
  57. Nlm_CharPtr LIBCALL Nlm_StrMove PROTO((char FAR *to, const char FAR *from));
  58. Nlm_CharPtr LIBCALL Nlm_StrSave PROTO((const char FAR *from));
  59. Nlm_sizeT LIBCALL Nlm_StrCnt PROTO((const char FAR *str, const char FAR *list));
  60.  
  61. Nlm_sizeT LIBCALL Nlm_StringLen PROTO((const char *str));
  62. Nlm_CharPtr LIBCALL Nlm_StringCpy PROTO((char FAR *to, const char FAR *from));
  63. Nlm_CharPtr LIBCALL Nlm_StringNCpy PROTO((char FAR *to, const char FAR *from, Nlm_sizeT max));
  64. Nlm_CharPtr LIBCALL Nlm_StringCat PROTO((char FAR *to, const char FAR *from));
  65. Nlm_CharPtr LIBCALL Nlm_StringNCat PROTO((char FAR *to, const char FAR *from, Nlm_sizeT max));
  66. int LIBCALL Nlm_StringCmp PROTO((const char FAR *a, const char FAR *b));
  67. int LIBCALL Nlm_StringNCmp PROTO((const char FAR *a, const char FAR *b, Nlm_sizeT max));
  68. int LIBCALL Nlm_StringICmp PROTO((const char FAR *a, const char FAR *b));
  69. int LIBCALL Nlm_StringNICmp PROTO((const char FAR *a, const char FAR *b, Nlm_sizeT max));
  70. Nlm_CharPtr LIBCALL Nlm_StringChr PROTO((const char FAR *str, int chr));
  71. Nlm_CharPtr LIBCALL Nlm_StringRChr PROTO((const char FAR *str, int chr));
  72. Nlm_CharPtr LIBCALL Nlm_StringPBrk PROTO((const char FAR *str1, const char FAR *str2));
  73. Nlm_sizeT LIBCALL Nlm_StringSpn PROTO((const char FAR *str1, const char FAR *str2));
  74. Nlm_sizeT LIBCALL Nlm_StringCSpn PROTO((const char FAR *str1, const char FAR *str2));
  75. Nlm_CharPtr LIBCALL Nlm_StringStr PROTO((const char FAR *str1, const char FAR *str2));
  76. Nlm_CharPtr LIBCALL Nlm_StringTok PROTO((char FAR *str1, const char FAR *str2));
  77. Nlm_CharPtr LIBCALL Nlm_StringMove PROTO((char FAR *to, const char FAR *from));
  78. Nlm_CharPtr LIBCALL Nlm_StringSave PROTO((const char FAR *from));
  79. Nlm_CharPtr LIBCALL Nlm_StringSaveNoNull PROTO((const char FAR *from));
  80. Nlm_sizeT LIBCALL Nlm_StringCnt PROTO((const char FAR *str, const char FAR *list));
  81. char* LIBCALL Nlm_StringUpper PROTO((char *string));
  82. char* LIBCALL Nlm_StringLower PROTO((char *string));
  83.  
  84. Nlm_Int2 LIBCALL Nlm_MeshStringICmp PROTO((const char FAR *str1, const char FAR *str2));
  85.  
  86. Nlm_Int2 LIBCALL Nlm_LabelCopy PROTO((Nlm_CharPtr to, Nlm_CharPtr from, Nlm_Int2 buflen));
  87. Nlm_Int2 LIBCALL Nlm_LabelCopyExtra PROTO((Nlm_CharPtr to, Nlm_CharPtr from, Nlm_Int2 buflen, Nlm_CharPtr prefix, Nlm_CharPtr suffix));
  88. void LIBCALL Nlm_LabelCopyNext PROTO((Nlm_CharPtr PNTR to, Nlm_CharPtr from, Nlm_Int2 PNTR buflen));
  89.  
  90.  
  91. /* aliases for ANSI functions */
  92. #ifdef WIN16
  93. #define Nlm_StrLen    _fstrlen
  94. #define Nlm_StrCpy    _fstrcpy
  95. #define Nlm_StrNCpy    _fstrncpy
  96. #define Nlm_StrCat    _fstrcat
  97. #define Nlm_StrNCat    _fstrncat
  98. #define Nlm_StrCmp    _fstrcmp
  99. #define Nlm_StrNCmp    _fstrncmp
  100. #define Nlm_StrChr    _fstrchr
  101. #define Nlm_StrRChr    _fstrrchr
  102. #define Nlm_StrCSpn    _fstrcspn
  103. #define Nlm_StrNSet    _fstrnset
  104. #define Nlm_StrPBrk    _fstrpbrk
  105. #define Nlm_StrSet    _fstrset
  106. #define Nlm_StrSpn    _fstrspn
  107. #define Nlm_StrStr    _fstrstr
  108. #define Nlm_StrTok    _fstrtok
  109. #else
  110. #define Nlm_StrLen    strlen
  111. #define Nlm_StrCpy    strcpy
  112. #define Nlm_StrNCpy    strncpy
  113. #define Nlm_StrCat    strcat
  114. #define Nlm_StrNCat    strncat
  115. #define Nlm_StrCmp    strcmp
  116. #define Nlm_StrNCmp    strncmp
  117. #define Nlm_StrChr    strchr
  118. #define Nlm_StrRChr    strrchr
  119. #define Nlm_StrCSpn    strcspn
  120. #define Nlm_StrNSet    strnset
  121. #define Nlm_StrPBrk    strpbrk
  122. #define Nlm_StrSet    strset
  123. #define Nlm_StrSpn    strspn
  124. #define Nlm_StrStr    strstr
  125. #define Nlm_StrTok    strtok
  126. #endif
  127.  
  128. #ifdef COMP_MSC
  129. #define Nlm_StrUpper  _strupr
  130. #define Nlm_StrLower  _strlwr
  131. #else
  132. char * LIBCALL Nlm_StrUpper PROTO((char *string));
  133. char * LIBCALL Nlm_StrLower PROTO((char *string));
  134. #endif
  135.  
  136. #define StrLen    Nlm_StrLen
  137. #define StrCpy    Nlm_StrCpy
  138. #define StrNCpy    Nlm_StrNCpy
  139. #define StrCat    Nlm_StrCat
  140. #define StrNCat    Nlm_StrNCat
  141. #define StrCmp    Nlm_StrCmp
  142. #define StrNCmp    Nlm_StrNCmp
  143. #define StrICmp Nlm_StrICmp
  144. #define StrNICmp Nlm_StrNICmp
  145. #define StrChr    Nlm_StrChr
  146. #define StrRChr    Nlm_StrRChr
  147. #define StrCSpn    Nlm_StrCSpn
  148. #define StrNSet    Nlm_StrNSet
  149. #define StrPBrk    Nlm_StrPBrk
  150. #define StrSet    Nlm_StrSet
  151. #define StrSpn    Nlm_StrSpn
  152. #define StrStr    Nlm_StrStr
  153. #define StrTok    Nlm_StrTok
  154. #define StrMove Nlm_StrMove
  155. #define StrSave Nlm_StrSave
  156. #define StrCnt  Nlm_StrCnt
  157. #define StrUpper Nlm_StrUpper
  158. #define StrLower Nlm_StrLower
  159.  
  160. #define StringLen    Nlm_StringLen
  161. #define StringCpy    Nlm_StringCpy
  162. #define StringNCpy    Nlm_StringNCpy
  163. #define StringCat    Nlm_StringCat
  164. #define StringNCat    Nlm_StringNCat
  165. #define StringCmp    Nlm_StringCmp
  166. #define StringNCmp    Nlm_StringNCmp
  167. #define StringICmp    Nlm_StringICmp
  168. #define StringNICmp    Nlm_StringNICmp
  169. #define StringChr   Nlm_StringChr
  170. #define StringRChr  Nlm_StringRChr
  171. #define StringPBrk  Nlm_StringPBrk
  172. #define StringSpn   Nlm_StringSpn
  173. #define StringCSpn  Nlm_StringCSpn
  174. #define StringStr   Nlm_StringStr
  175. #define StringTok   Nlm_StringTok
  176. #define StringMove    Nlm_StringMove
  177. #define StringSave    Nlm_StringSave
  178. #define StringSaveNoNull Nlm_StringSaveNoNull
  179. #define StringCnt   Nlm_StringCnt
  180. #define StringUpper Nlm_StringUpper
  181. #define StringLower Nlm_StringLower
  182.  
  183. #define MeshStringICmp Nlm_MeshStringICmp
  184. #define LabelCopy Nlm_LabelCopy
  185. #define LabelCopyExtra Nlm_LabelCopyExtra
  186.  
  187.  
  188.  
  189. /*----------------------------------------*/
  190. /*      Misc Text Oriented Macros         */
  191. /*----------------------------------------*/
  192.  
  193. #define IS_DIGIT(c)    ('0'<=(c) && (c)<='9')
  194. #define IS_UPPER(c)    ('A'<=(c) && (c)<='Z')
  195. #define IS_LOWER(c)    ('a'<=(c) && (c)<='z')
  196. #define IS_ALPHA(c)    (IS_UPPER(c) || IS_LOWER(c))
  197. #define TO_LOWER(c)    ((Nlm_Char)(IS_UPPER(c) ? (c)+' ' : (c)))
  198. #define TO_UPPER(c)    ((Nlm_Char)(IS_LOWER(c) ? (c)-' ' : (c)))
  199. #define IS_WHITESP(c) (((c) == ' ') || ((c) == '\n') || ((c) == '\r') || ((c) == '\t'))
  200. #define IS_ALPHANUM(c) (IS_ALPHA(c) || IS_DIGIT(c))
  201.  
  202. #ifdef __cplusplus
  203. }
  204. #endif
  205.  
  206. #endif
  207.